<template>
  <div class="app-container">
    <GoodsOverviewHistoryDetailEdit ref="openGoodsOverviewHistoryDetailEdit" @refresh="refresh"></GoodsOverviewHistoryDetailEdit>
    <el-form @submit.native.prevent :model="showData" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="120px" :label-position="labelPosition">
      <el-form-item label="客户条码" prop="sptm">
        <el-input
          v-model="showData.sptm"
          :disabled="true"
        />
      </el-form-item>
      <el-form-item label="截至日期至" prop="day1">
        <el-input
          v-model="showData.day1"
          :disabled="true"
        />
      </el-form-item>
      <el-form-item label="剩余重量(吨)" prop="spsl">
        <el-input
          v-model="showData.spsl"
          :disabled="true"
        />
      </el-form-item>
    </el-form>
    
    <el-row v-show="warehouseInShow">
        <el-col :span="1.5">入仓单</el-col>
    </el-row>
    <el-table
      v-show="warehouseInShow"
      v-loading="loading"
      :data="historyDetailList['h2020080430685917']"
    >
      <af-table-column width="50">
        <template slot-scope="scope">
          {{scope.$index + 1}}
        </template>
      </af-table-column>  
      <af-table-column prop="pzbh" label="单号"></af-table-column>
      <af-table-column prop="prrq" label="创建时间"></af-table-column>
      <af-table-column prop="rsopmc" label="创建人"></af-table-column>
      <af-table-column prop="spckmc" label="仓库"></af-table-column>
      <af-table-column prop="ckcw" label="仓位"></af-table-column>
      <af-table-column prop="spjs" label="件数"></af-table-column>
      <af-table-column prop="spjsl" label="单重(KG)"></af-table-column>
      <af-table-column prop="spsl" label="重量(吨)"></af-table-column>
      <af-table-column prop="itbz" label="备注" width="150" :show-overflow-tooltip="true"></af-table-column>
      <af-table-column prop="ssrqid" label="入仓日期"></af-table-column>
    </el-table>
    <el-row class="mt20" v-show="warehouseOutShow">
        <el-col :span="1.5">出仓单</el-col>
    </el-row>
    <el-table
      v-show="warehouseOutShow"
      v-loading="loading"
      :data="historyDetailList['h2020080482805760']"
    >
      <af-table-column width="50">
        <template slot-scope="scope">
          {{scope.$index + 1}}
        </template>
      </af-table-column>  
      <af-table-column prop="pzbh" label="单号"></af-table-column>
      <af-table-column prop="prrq" label="创建时间"></af-table-column>
      <af-table-column prop="rsopmc" label="创建人"></af-table-column>
      <af-table-column prop="spckmc" label="仓库"></af-table-column>
      <af-table-column prop="ckcw" label="仓位"></af-table-column>
      <af-table-column prop="spjs" label="件数"></af-table-column>
      <af-table-column prop="spjsl" label="单重(KG)"></af-table-column>
      <af-table-column prop="spsl" label="重量(吨)"></af-table-column>
      <af-table-column prop="itbz" label="备注" width="150" :show-overflow-tooltip="true"></af-table-column>
      <af-table-column prop="ssrqid" label="出仓日期"></af-table-column>
    </el-table>
    <el-row class="mt20" v-show="warehouseMoveShow">
        <el-col :span="1.5">调拨单</el-col>
    </el-row>
    <el-table
      v-show="warehouseMoveShow"
      v-loading="loading"
      :data="historyDetailList['h2020080426088740']"
    >
      <af-table-column width="50">
        <template slot-scope="scope">
          {{scope.$index + 1}}
        </template>
      </af-table-column>  
      <af-table-column prop="pzbh" label="单号"></af-table-column>
      <af-table-column prop="prrq" label="创建时间"></af-table-column>
      <af-table-column prop="rsopmc" label="创建人"></af-table-column>
      <af-table-column prop="spckmc1" label="原仓库"></af-table-column>
      <af-table-column prop="ckcw1" label="原仓位"></af-table-column>
      <af-table-column prop="spckmc2" label="新仓库"></af-table-column>
      <af-table-column prop="ckcw2" label="新仓位"></af-table-column>
      <af-table-column prop="spjs" label="调拨件数"></af-table-column>
      <af-table-column prop="spjsl" label="单重(KG)"></af-table-column>
      <af-table-column prop="spsl" label="调拨重量(吨)"></af-table-column>
      <af-table-column prop="itbz" label="备注" width="150" :show-overflow-tooltip="true"></af-table-column>
      <af-table-column prop="ssrqid" label="调拨日期"></af-table-column>
    </el-table>
    <el-row class="mt20" v-show="warehousePropertyShow">
        <el-col :span="1.5">货权转移单</el-col>
    </el-row>
    <el-table
    v-show="warehousePropertyShow"
      v-loading="loading"
      :data="historyDetailList['h2020080434496398']"
    >
      <af-table-column width="50">
        <template slot-scope="scope">
          {{scope.$index + 1}}
        </template>
      </af-table-column>  
      <af-table-column prop="pzbh" label="单号"></af-table-column>
      <af-table-column prop="prrq" label="创建时间"></af-table-column>
      <af-table-column prop="rsopmc" label="创建人"></af-table-column>
      <af-table-column prop="sptm1" label="原条码"></af-table-column>
      <af-table-column prop="khmc1" label="原所有人"></af-table-column>
      <af-table-column prop="sptm2" label="新条码"></af-table-column>
      <af-table-column prop="khmc2" label="新所有人"></af-table-column>
      <af-table-column prop="spckmc" label="仓库"></af-table-column>
      <af-table-column prop="ckcw" label="仓位"></af-table-column>
      <af-table-column prop="spjs" label="转移件数"></af-table-column>
      <af-table-column prop="spjsl" label="单重(KG)"></af-table-column>
      <af-table-column prop="spsl" label="转移重量(吨)"></af-table-column>
      <af-table-column prop="itbz" label="备注" width="150" :show-overflow-tooltip="true"></af-table-column>
      <af-table-column prop="ssrqid" label="调仓日期"></af-table-column>
    </el-table>
     <el-row class="mt20" v-show="warehousePledgeShow">
        <el-col :span="1.5">货权质押单</el-col>
    </el-row>
   <el-table
      v-show="warehousePledgeShow"
      v-loading="loading"
      :data="historyDetailList['h2020080448403170']"
    >
      <af-table-column width="50">
        <template slot-scope="scope">
          {{scope.$index + 1}}
        </template>
      </af-table-column>  
      <af-table-column prop="pzbh" label="单号"></af-table-column>
      <af-table-column prop="prrq" label="创建时间"></af-table-column>
      <af-table-column prop="rsopmc" label="创建人"></af-table-column>
      <af-table-column prop="spckmc" label="仓库"></af-table-column>
      <af-table-column prop="ckcw" label="仓位"></af-table-column>
      <af-table-column prop="spjs" label="转移件数"></af-table-column>
      <af-table-column prop="spjsl" label="单重(KG)"></af-table-column>
      <af-table-column prop="spsl" label="转移重量(吨)"></af-table-column>
      <af-table-column prop="itbz" label="备注" width="150" :show-overflow-tooltip="true"></af-table-column>
      <af-table-column prop="ssrqid" label="质押日期"></af-table-column>
    </el-table>
     <el-row class="mt20" v-show="warehouseReleaseShow">
        <el-col :span="1.5">货权解押单</el-col>
    </el-row>
    <el-table
      v-show="warehouseReleaseShow"
      v-loading="loading"
      :data="historyDetailList['h2020080441992316']"
    >
      <af-table-column width="50">
        <template slot-scope="scope">
          {{scope.$index + 1}}
        </template>
      </af-table-column>  
      <af-table-column prop="pzbh" label="单号"></af-table-column>
      <af-table-column prop="prrq" label="创建时间"></af-table-column>
      <af-table-column prop="rsopmc" label="创建人"></af-table-column>
      <af-table-column prop="spckmc" label="仓库"></af-table-column>
      <af-table-column prop="ckcw" label="仓位"></af-table-column>
      <af-table-column prop="spjs" label="转移件数"></af-table-column>
      <af-table-column prop="spjsl" label="单重(KG)"></af-table-column>
      <af-table-column prop="spsl" label="转移重量(吨)"></af-table-column>
      <af-table-column prop="itbz" label="备注" width="150" :show-overflow-tooltip="true"></af-table-column>
      <af-table-column prop="ssrqid" label="解押日期"></af-table-column>
    </el-table>
     <el-row class="mt20" v-show="warehousePledgeReadShow">
        <el-col :span="1.5">质押(仅查看)</el-col>
    </el-row>
    <el-table
      v-show="warehousePledgeReadShow"
      v-loading="loading"
      :data="historyDetailList['h2021012113949524']"
    >
      <af-table-column width="50">
        <template slot-scope="scope">
          {{scope.$index + 1}}
        </template>
      </af-table-column>  
      <af-table-column prop="pzbh" label="单号"></af-table-column>
      <af-table-column prop="prrq" label="创建时间"></af-table-column>
      <af-table-column prop="rsopmc" label="创建人"></af-table-column>
      <af-table-column prop="spckmc" label="仓库"></af-table-column>
      <af-table-column prop="ckcw" label="仓位"></af-table-column>
      <af-table-column prop="spjs" label="件数"></af-table-column>
      <af-table-column prop="spjsl" label="单重(KG)"></af-table-column>
      <af-table-column prop="spsl" label="重量(吨)"></af-table-column>
      <af-table-column prop="itbz" label="备注" width="150" :show-overflow-tooltip="true"></af-table-column>
      <af-table-column prop="ssrqid" label="质押日期"></af-table-column>
    </el-table>
     <el-row class="mt20" v-show="warehouseReleaseReadShow">
        <el-col :span="1.5">解押(仅查看)</el-col>
    </el-row>
    <el-table
      v-show="warehouseReleaseReadShow"
      v-loading="loading"
      :data="historyDetailList['h2021012180274975']"
    >
      <af-table-column width="50">
        <template slot-scope="scope">
          {{scope.$index + 1}}
        </template>
      </af-table-column>  
      <af-table-column prop="pzbh" label="单号"></af-table-column>
      <af-table-column prop="prrq" label="创建时间"></af-table-column>
      <af-table-column prop="rsopmc" label="创建人"></af-table-column>
      <af-table-column prop="spckmc" label="仓库"></af-table-column>
      <af-table-column prop="ckcw" label="仓位"></af-table-column>
      <af-table-column prop="spjs" label="件数"></af-table-column>
      <af-table-column prop="spjsl" label="单重(KG)"></af-table-column>
      <af-table-column prop="spsl" label="重量(吨)"></af-table-column>
      <af-table-column prop="itbz" label="备注" width="150" :show-overflow-tooltip="true"></af-table-column>
      <af-table-column prop="ssrqid" label="解押日期"></af-table-column>
    </el-table>
     <el-row class="mt20" v-show="warehouseSaleShow">
        <el-col :span="1.5">货物销售</el-col>
    </el-row>
    <el-table
      v-show="warehouseSaleShow"
      v-loading="loading"
      :data="historyDetailList['h2021012957335439']"
    >
      <af-table-column width="50">
        <template slot-scope="scope">
          {{scope.$index + 1}}
        </template>
      </af-table-column>  
      <af-table-column prop="pzbh" label="单号"></af-table-column>
      <af-table-column prop="prrq" label="创建时间"></af-table-column>
      <af-table-column prop="rsopmc" label="创建人"></af-table-column>
      <af-table-column prop="spckmc" label="仓库"></af-table-column>
      <af-table-column prop="ckcw" label="仓位"></af-table-column>
      <af-table-column prop="spjs" label="件数"></af-table-column>
      <af-table-column prop="spjsl" label="单重(KG)"></af-table-column>
      <af-table-column prop="spsl" label="重量(吨)"></af-table-column>
      <af-table-column prop="itbz" label="备注" width="150" :show-overflow-tooltip="true"></af-table-column>
      <af-table-column prop="ssrqid" label="出仓日期"></af-table-column>
    </el-table>
    <el-row type="flex" justify="center" :gutter="5" class="mt20">
      <el-col :span="1.5">
        <el-button type="primary" @click="editDetail" v-hasPermi="['zhcloud:sjzl:modify']">修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button @click="goBack">返回</el-button>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { getHistoryDetail } from "@/api/storage/dataOverview/goodsOverview";
import GoodsOverviewHistoryDetailEdit from './goodsOverviewHistoryDetailEdit.vue'

export default {
  name: "GoodsOverviewHistoryDetail",
  components:{ GoodsOverviewHistoryDetailEdit },
  data() {
    return {
      // 显示搜索条件
      showSearch: true,
      //表格加载
      loading:true,
       //对齐
      labelPosition: "right",
      //客户加载
      selectClient3Loading:true,
      warehouseInDetailDate:'',
      // 查询参数
      queryParams: {
        spbhid: "",
        sptm: "",
      },
      //显示数据
      showData: {
        sptm:"",
        day1:"",
        spsl:""
      },
      //获取客户参数
      selectClient3Query: {
        name1:""
      },
      // 入仓明细列表
      historyDetailList: [],
      //客户列表
      client3List: [],
    };
  },
  beforeRouteEnter(to, from, next) {
    const query = to.query
    next(vm => {   
      if(Object.keys(query).length > 0) {
        vm.queryParams = {
          spbhid:query.spbhid,
          sptm:query.sptm
        }
        vm.showData = query
        vm.getList()
      }
    })
  },
  computed: {
    warehouseInShow() {
      const data = this.historyDetailList['h2020080430685917']
      return data && data.length > 0?true:false
    },
    warehouseOutShow() {
      const data = this.historyDetailList['h2020080482805760']
      return data && data.length > 0?true:false
    },
    warehouseMoveShow() {
      const data = this.historyDetailList['h2020080426088740']
      return data && data.length > 0?true:false
    },
    warehousePropertyShow() {
      const data = this.historyDetailList['h2020080434496398']
      return data && data.length > 0?true:false
    },
    warehousePledgeShow() {
      const data = this.historyDetailList['h2020080448403170']
      return data && data.length > 0?true:false
    },
    warehouseReleaseShow() {
      const data = this.historyDetailList['h2020080441992316']
      return data && data.length > 0?true:false
    },
    warehousePledgeReadShow() {
      const data = this.historyDetailList['h2021012113949524']
      return data && data.length > 0?true:false
    },
    warehouseReleaseReadShow() {
      const data= this.historyDetailList['h2021012180274975']
      return data && data.length > 0?true:false
    },
    warehouseSaleShow() {
      const data = this.historyDetailList['h2021012957335439']
      return data && data.length > 0?true:false
    },
  },
  methods: {
    /** 历史信息 */
    getList() {
      this.loading = true
      getHistoryDetail(this.queryParams, {pageNum:this.pageNum, pageSize:this.pageSize}).then(response => {
        this.historyDetailList = response.data;
        this.loading = false
      });
    },

    /** 修改信息*/
    editDetail() {
      const data = this.showData
      this.$refs.openGoodsOverviewHistoryDetailEdit.open(data)
    },
    /** 刷新数据*/
    refresh() {
      this.getList()
      this.goGoodsOverview()
    },
    /**返回数据总览页 */
    goGoodsOverview() {
      this.$tab.closePage(this.$route)
      this.$router.push({name:"GoodsOverview", params:{refresh:true}})
    },

    /**返回不刷新 */
    goBack() {
      this.$router.push({name:"GoodsOverview"})
    },
    reset() {
      Object.assign(this.$data, this.$options.data())
    },
  }
};
</script>
